<template>
  <div>
    <publicPageVue :btn-fix="true" :json-obj="pageSetting" name="Timer" :tables="tables" />
    <!-- <VuiCron v-model="demo" /> -->
  </div>
</template>

<script>
  import { Mixin } from '@/common/minxin/Mixin'
  import { GFCD } from '@/utils/utils'
  import publicPageVue from '../../../components/publicPage.vue'
  import { getList } from '../../../api/home'
  import Timer from '../../../components/json/Timer'
  export default {
    name: 'Timer',
    components: { publicPageVue },
    mixins: [Mixin],
    data() {
      return {
        demo: '',
        tables: {
          tableList: [],
          count: 0,
          pageSize: 50,
          limit: 1,
          name: 'Timer',
          operation: false,
          isNew: true,
          width: '250',
        },
        configSetting: {},
        pageSetting: {
          search: {
            form: {
              field: [],
            },
          },
        },
      }
    },
    created() {
      this.init()
    },
    methods: {
      async init() {
        this.configSetting = GFCD('dams')
        let res = await this.getTimerGroup()
        let res1 = await this.getSubsystemData()
        let list = []
        let list1 = []
        res.forEach((item) => {
          list.push({ CODE: item.GROUP_NAME, LABEL: item.GROUP_CN_DESC, TIMER_HOST: item.TIMER_HOST })
        })
        res1.forEach((item) => {
          list1.push({ CODE: item.CODE, LABEL: item.LABEL })
        })
        // this.nowJsonData().then((data) => {
        //   console.log(data)
        this.pageSetting = Timer
        let listField = this.pageSetting.Timer.dialog.form.field
        let listField1 = this.pageSetting.Timer.search.form.field
        listField.forEach((item) => {
          if (item.name == 'TIMER_GROUP') {
            item.options = list
          }
          if (item.name == 'SUB_SYSTEM') {
            item.options = list1
          }
        })
        listField1.forEach((item) => {
          if (item.name == 'SUB_SYSTEM') {
            item.options = list1
          }
        })
        // })
      },
      //获取定时器分组下拉数据
      async getTimerGroup() {
        let method = 'dams.app.timer.group.query'
        let res = await getList(`${this.configSetting.domain}${this.configSetting.baseUrl}`, {
          method: method,
          data: JSON.stringify({ '#LIMIT#': 1, '#PAGE_SIZE#': 9999 }),
        })
        return res.data[method].data
      },
      //获取子系统下拉数据
      async getSubsystemData() {
        let method = 'dams.handle.flow.query.options'
        let res = await getList(`${this.configSetting.domain}${this.configSetting.baseUrl}`, {
          method: method,
          data: JSON.stringify({ '#LIMIT#': 1, '#PAGE_SIZE#': 9999 }),
        })
        return res.data.SUB_SYSTEM.data
      },
    },
  }
</script>

<style lang="scss" scoped></style>
